import 'package:k3cloud_api/params/iface_model.dart';
import 'package:k3cloud_api/params/model/user_context.dart';

class LoginInfo implements IModel {
  String? message;
  String? messageCode;
  int? loginResultType;
  UserContext? context;
  String? kDSVCSessionId;
  String? formId;
  String? redirectFormParam;
  String? formInputObject;
  String? errorStackTrace;
  int? lcid;
  String? accessToken;
  String? kdAccessResult;
  bool? isSuccessByAPI;

  bool get isLoginSuccess => loginResultType == 1;

  LoginInfo.fromJson(Map<String, dynamic> json) {
    message = json["Message"];
    messageCode = json["MessageCode"];
    loginResultType = json["LoginResultType"];
    context = json["Context"] == null ? null : UserContext.fromJson(json["Context"]);
    kDSVCSessionId = json["KDSVCSessionId"];
    formId = json["FormId"];
    redirectFormParam = json["RedirectFormParam"];
    formInputObject = json["FormInputObject"];
    errorStackTrace = json["ErrorStackTrace"];
    lcid = json["Lcid"];
    accessToken = json["AccessToken"];
    kdAccessResult = json["KdAccessResult"];
    isSuccessByAPI = json["IsSuccessByAPI"];
  }

  @override
  Map<String, dynamic> toJson() => {
    "Message": message,
    "MessageCode": messageCode,
    "LoginResultType": loginResultType,
    "Context": context?.toJson(),
    "KDSVCSessionId": kDSVCSessionId,
    "FormId": formId,
    "RedirectFormParam": redirectFormParam,
    "FormInputObject": formInputObject,
    "ErrorStackTrace": errorStackTrace,
    "Lcid": lcid,
    "AccessToken": accessToken,
    "KdAccessResult": kdAccessResult,
    "IsSuccessByAPI": isSuccessByAPI,
  };
}